layui.config({
	base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		layedit = layui.layedit,
		laydate = layui.laydate,
		$ = layui.jquery;

	//创建一个编辑器
 	var editIndex = layedit.build('news_content');
 	var addNewsArray = [],addNews;
 	
 	var orgId = window.sessionStorage.getItem("organizeId"); 	
 	form.on("submit(subInfo)",function(data){
 		layedit.sync(editIndex);
 		var data ={
 			name:$(".name").val(),
 			introduce:$("#news_content").val(),
 			orgId:orgId
 		}
 		//弹出loading
 		var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        addProfession(data,function(){
        	top.layer.close(index);
 			layer.closeAll("iframe");
	 		//刷新父页面
	 		parent.location.reload();
        })
 		return false;
 	})
	
})
function addProfession(data,callback) {
    $.ajax({
        url: $.httpRootPath()+'/api/web/profession/i/'+data.orgId,
        type: 'POST',
        dataType: 'json',
        data: data,
        timeout: 15000,
        cache: false,
        success: function (r) {
            if (r.code == "00") {
              	layer.msg("添加成功！");
            } else {
               layer.msg(r.msg);
            }
            callback();

        },
        error: function (e) {
          layer.msg("系统错误！");
        },
        complete:function(){
        	callback();
        }
    });

}

